Skip to content

Conversation

@yonghanlin
Copy link

What does this PR do

This PR fixes a test failure in PartitionByRangeDateHashTest.test() within . module by setting the timezone to UTC for all date parsing and formatting operations. It also updates the corresponding test (PartitionByRangeDateHashTest) to generate and validate timestamps in UTC for consistent results.

Problem

The previous implementation of PartitionByRangeDateHash used SimpleDateFormat without specifying a timezone, which defaulted to the system’s local timezone. This caused inconsistent partition calculations and test failures when the code was run on machines in different timezones. The same input timestamp could map to a different partition depending on the local environment.

Reproduce Test

Run either one of the following commands in two environments with different timezones:

mvn -pl . test -Dtest=io.mycat.route.function.PartitionByRangeDateHashTest#test
mvn -pl . edu.illinois:nondex-maven-plugin:2.1.7:nondex -Dtest=io.mycat.route.function.PartitionByRangeDateHashTest#test

The test PartitionByRangeDateHashTest will fail on one environment but pass on another due to timezone differences affecting SimpleDateFormat parsing.

The Fix

  • Set SimpleDateFormat to use UTC for both initialization (beginDate) and parsing (formatter).
  • Adjusted PartitionByRangeDateHashTest to generate timestamps in UTC to align with the updated logic.
  • Upgraded the JUnit version to ensure better compatibility with modern NonDex and Maven Surefire environments.

@yonghanlin yonghanlin force-pushed the fix/partition-datehash branch from 4b545b2 to 6b4d624 Compare October 23, 2025 11:21
@yonghanlin yonghanlin changed the title Fix unspecified timezone in PartitionByRangeDateHash and adjust test expectations fix: specify timezone in PartitionByRangeDateHash and adjust test expectations Oct 23, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant